import { BasicColumn, FormSchema } from '@/components/Table';
import { Status, StatusTag, StatusOptions } from '@/enums/fieldsEnum';
import defaultSetting from '@/settings/projectSetting';

export const columns: BasicColumn[] = [
  {
    title: '部门名称',
    dataIndex: 'dept_name',
    width: 200,
    align: 'left',
  },
  {
    title: '排序',
    dataIndex: 'sort',
    width: 50,
  },
  {
    title: '状态',
    dataIndex: 'status',
    width: 80,
    customRender: ({ record }) => StatusTag(record.status),
  },
  {
    title: '创建时间',
    dataIndex: 'created_at',
    width: 200,
  },
  {
    title: '备注',
    dataIndex: 'remark',
  },
];

export const formSchema: FormSchema[] = [
  {
    field: 'dept_id',
    label: '部门ID',
    component: 'InputNumber',
    show: false,
  },
  {
    field: 'dept_name',
    label: '部门名称',
    component: 'Input',
    required: true,
  },
  {
    field: 'parent_id',
    label: '上级部门',
    component: 'TreeSelect',
    componentProps: {
      fieldNames: {
        label: 'dept_name',
        value: 'dept_id',
      },
      getPopupContainer: () => document.body,
    },
  },
  {
    field: 'sort',
    label: '排序',
    component: 'InputNumber',
  },
  {
    field: 'status',
    label: '状态',
    component: 'RadioButtonGroup',
    defaultValue: Status.Enabled,
    componentProps: {
      options: StatusOptions,
    },
    required: true,
  },
  {
    label: '备注',
    field: 'remark',
    component: 'InputTextArea',
  },
];
